<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\FamilyCompetition;
use App\Model\OperationLogs;

class FamilyCompetitionController extends BaseController
{

    protected $model = null;
    /**
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new FamilyCompetition();
    }

    //全家总动员获取配置
    public function getConfig(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->getConfig($request));
    }

    //全家总动员更新配置
    public function configUpdate(Request $request){
        $res = $this->model->configUpdate($request);
        if(is_array($res)) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        // OperationLogs::createData($request, OperationLogs::ACTIVITY, '全家总动员更新配置');
        return $this->toJson(self::SUCCESS);
    }

    //全家总动员统计整体数据
    public function statSearchAll(Request $request){
        $res = $this->model->statSearchAll($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //全家总动员统计单期数据
    public function statGameEvery(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->statGameEvery($request));
    }

    //全家总动员用户参与明细
    public function statUserInfo(Request $request){
        $res = $this->model->statUserInfo($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //全家总动员商店兑换数据
    public function statShopList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->statShopList($request));
    }

}
